import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

import Dashboard from '../views/index/Dashboard.vue'

import ConfigTemplates from '../views/cluster/ConfigTemplates.vue'
import AddTemplate from '../views/cluster/AddTemplate.vue'
import EditTemplate from '../views/cluster/EditTemplate.vue'
import ClusterList from '../views/cluster/ClusterList.vue'
import AddCluster from '../views/cluster/AddCluster.vue'
import AddNode from '../views/cluster/AddNode.vue'
import ClusterManagement from '../views/cluster/ClusterManagement.vue'

import MonitorService from '../views/monitor/MonitorService.vue'
import MonitorServicePage from '../views/monitor/MonitorServicePage.vue'
import PrometheusConfigPage from '../views/monitor/ConfigPageForPrometheus.vue'
import GrafanaConfigPage from '../views/monitor/ConfigPageForGrafana.vue'
import MonitorDashboards from '../views/monitor/MonitorDashboards.vue'
import NewDashboard from '../views/monitor/NewDashboard.vue'

import Notifications from '../views/alerting/Notifications.vue'
import AlertList from '../views/alerting/AlertList.vue'

import ClusterMessage from '../views/events/ClusterMessage.vue'
import MonitorMessage from '../views/events/MonitorMessage.vue'
import AlertMessage from '../views/events/AlertMessage.vue'

import Histories from '../views/history/Histories.vue'
import Reports from '../views/history/Reports.vue'


Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Home',
    component: Home,

    children: [
        // 首页
        { path: '/dashboard', component: Dashboard },

        // 集群管理
        { path: '/templates', component: ConfigTemplates },
        { path: '/templates/add', component: AddTemplate },
        { path: '/templates/edit', component: EditTemplate },
        { path: '/cluster', component: ClusterList },
        { path: '/cluster/add', component: AddCluster },
        { path: '/node/add', component: AddNode },
        { path: '/clustermgr', component: ClusterManagement },

        // 监控管理
        { path: '/service', component: MonitorService },
        { path: '/service/servicePage', component: MonitorServicePage },
        { path: '/service/prometheusConfig', component: PrometheusConfigPage },
        { path: '/service/grafanaConfig', component: GrafanaConfigPage },
        { path: '/monitorDashboards', component: MonitorDashboards },
        { path: '/monitorDashboards/newDashboard', component: NewDashboard },

        // 预警管理
        { path: '/notifications', component: Notifications },
        { path: '/alert', component: AlertList },

        // 事件消息
        { path: '/clusterMsg', component: ClusterMessage },
        { path: '/monitorMsg', component: MonitorMessage },
        { path: '/alertMsg', component: AlertMessage },

        // 历史&报表
        { path: '/histories', component: Histories },
        { path: '/reports', component: Reports },
    ]
}]

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push (location) {
    return routerPush.call(this, location).catch(error => error)
}

const router = new VueRouter({
    routes
})

export default router